package com.house.business.controller;

import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.house.business.service.FaultService;
import com.house.business.entity.Fault;
import com.house.business.vo.FaultVo;
import org.springframework.web.bind.annotation.RestController;
import com.house.framework.controller.BaseController;

/**
 * <p>
 * 故障表 前端控制器
 * </p>
 *
 * @since 2023-05-09
 */
@Slf4j
@RestController
@RequestMapping("/faultController")
public class FaultController extends BaseController {

    @Autowired
    private FaultService faultService;
    /**
    * 新增故障表
    * @param entity
    * t_fault新增数据
    * @return 新增数据id
    */
    @ApiOperation(value = "故障表", notes = "新增故障表")
    @RequestMapping(value = "/addFault", method = RequestMethod.POST)
    public Object addFault(@RequestBody Fault entity) {
        return faultService.addFault(entity);
    }

    /**
    * 修改故障表
    * @param entity
    * t_fault修改数据
    * @return 修改记录数
    */
    @ApiOperation(value = "故障表", notes = "修改故障表")
    @RequestMapping(value = "/updateFault", method = RequestMethod.POST)
    public Object updateFault(@RequestBody Fault entity) {
        return faultService.updateFault(entity);
    }

    /**
    * 取指定ID的故障表数据
    * @param id
    * t_fault 主键ID
    * @return 返回实体对象
    * 返回指定id 故障表数据
    */
    @ApiOperation(value = "故障表", notes = "取故障表")
    @RequestMapping(value = "/getFaultById", method = RequestMethod.GET)
    public FaultVo getFaultById(@RequestParam Long id) {
        return faultService.getFaultById(id);
    }

    /**
    * 故障表分页取数
    * @param entityVo
    * t_fault 分页取数参数，pageIndex=页码；pageSize=每页记录数；
    * @return
    * 返回分页数据
    */
    @RequestMapping(value = "/getFaultList", method = RequestMethod.POST)
    public IPage<FaultVo> getFaultList(@RequestBody FaultVo entityVo){
        IPage<FaultVo> page = faultService.getFaultList(entityVo);
        return page;
    }

    /**
    * 删除指定ID的故障表数据
    * @param id
    * t_fault 主键ID
    */
    @ApiOperation(value = "故障表", notes = "删除故障表")
    @RequestMapping(value = "/deleteFaultById/{id}", method = RequestMethod.GET)
    public void deleteFaultById(@PathVariable("id") Long id) {
         faultService.deleteFaultById(id);
    }

    /**
    * 批量删除指定ID的故障表数据
    * @param ids
    * t_fault 主键ID
    */
    @ApiOperation(value = "故障表", notes = "批量删除故障表")
    @RequestMapping(value = "/batchDelete", method = RequestMethod.POST)
    public void batchDelete(@RequestParam Long[] ids) {
        faultService.batchDelete(ids);
    }

}
